using System;

using Slaks.Descriptions;

namespace Slaks.Filters
{
	[ModuleDescriptionAttribute("English basic term filter","Slava Kisilevich")]
	public class EnglishTermFilter : Slaks.Filters.AFilter
	{
    protected static int EnglishCapitalLetterBegin = 0x41;
    protected static int EnglishCapitalLetterEnd = 0x5a;

    protected static int EnglishSmallLetterBegin = 0x61;
    protected static int EnglishSmallLetterEnd = 0x7a;

    protected static int DigitZero = 0x30;
    protected static int DigitNine = 0x39;

    protected static int HypherLine = 0x2d;

    public EnglishTermFilter(){}

    /// <summary>
    /// All non english letters are considered white space.
    /// </summary>
    /// <param name="ch"></param>
    /// <returns></returns>
        public override bool IsWhiteSpace(char ch)
        {
            if (ch < EnglishCapitalLetterBegin) return true;
            if (ch > EnglishCapitalLetterEnd &&
              ch < EnglishSmallLetterBegin) return true;
            if (ch > EnglishSmallLetterEnd) return true;
            return false;
        }

        
    /// <summary>
    /// Normalizes the character by lowering
    /// </summary>
    /// <param name="ch"></param>
    /// <returns></returns>
    public override char Normalize(char ch)
    {
      return char.ToLower(ch);
    }

		public override bool IsEndOfSentencePunctuationMark(char ch)
		{
			if (ch == GeneralEndOfSentencePunctuationMarkDot ||
				ch == GeneralEndOfSentencePunctuationMarkExclamation ||
				ch == GeneralEndOfSentencePunctuationMarkQuestion) return true;

			return false;
		}

		public override bool IsMiddleSentencePunctuationMark(char ch)
		{
			if (ch == GeneralMiddleOfSentencePunctuationMarkComma) return true;
			return false;
		}

    public override string ToString()
    {
      return "english filter";
    }

	}
}
